<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of generarReporteCajaSuccess
 *
 * @author Marcelo
 */

?>
<?php use_helper('Form')?>
<?php use_stylesheet('/sfPropelPlugin/css/global.css') ?>
<?php use_stylesheet('/sfPropelPlugin/css/default.css') ?>



<div id="sf_admin_container">
    <h2>Detalles de Estado de Caja</h2>
    
<table>
    <thead>
    <tr>
    <th>ITEM</th>
    <th>CATEGORIA</th>
    <th>INGRESO</th>
    <th>EGRESO</th>
    <th>SALDO</th>
    <tr>
    </thead>
    <tbody>
        <?php $e = 1;$total=$cierre->getCierreAnterior();$totalegresos=0;$saldo=0 ?>
        <tr>
        <td><?php echo $e++?></td>
        <td>Cierre Anterior</td>
        <td><?php echo number_format($total,0,'','.').' Gs';?></td>
        <td>0</td>
        <td>
        <?php $saldo += $cierre->getCierreanterior();
            echo number_format($saldo,0,'','.').' Gs'?></td>
        </tr>
        <?php if ($detalles): ?>
            <?php foreach($detalles as $caja):?>
            <tr>
            <td><?php echo $e++?></td>
            <td><?php echo $caja['categorias']?></td>
            <td><?php echo number_format($caja['Total_Ingreso'],0,'','.').' Gs'?></td>
            <td><?php echo number_format($caja['Total_Egreso'],0,'','.').' Gs'?></td>
            <td>
            <?php $saldo += $caja['Total_Ingreso']-$caja['Total_Egreso'];
                echo number_format($saldo,0,'','.').' Gs'?></td>
            </tr>
            <?php $total += $caja['Total_Ingreso'];$totalegresos +=$caja['Total_Egreso']; endforeach; ?>
        <?php endif;?>
    </tbody>
    <tfoot>
    <tr>
    <th></th>
        <th></th>
        <th>Total Ingresos: <?php echo number_format($total,0,'','.').' Gs'?></th>
        <th style="color: red">Total Egresos: <?php  echo number_format($totalegresos,0,'','.').' Gs'?></th>
        <th></th>
    </tr>
    </tfoot>
</table>
<?php if(($total-$totalegresos) > 0):?>
    <div class="notice" style="width: 500px">El Saldo de la Caja es: <?php  echo number_format($total-$totalegresos,0,'','.').' Gs'?> </div>
 <?php else:?>
    <div class="error" style="width: 500px">El Saldo de la Caja es: <?php  echo number_format($total-$totalegresos,0,'','.').' Gs'?> </div>
 <?php endif;?>
    <div><input type="button" id="btnCerrarEImprimir" value="Cerrar Caja e Imprimir"></div>
 </div>
<script type="text/javascript">
//<![CDATA[
$('btnCerrarEImprimir').observe('click', function (envent){
   if (confirm('Realmente desea cerrar la caja?, ya no se podran modificar los movimientos')){
       document.location.href="<?php echo url_for('cierre_de_caja/cerrar?id='.$cierre->getId())?>";
   }
   else{
      return false;
   }
});
//]]>
</script>
